<template>
  <div class="container">
    <div class="cont-header">
      <div class="info-item">
        <img class="pic" :src="twitter.headUrl" alt="" />
        <div class="info">
          <div class="name">
            <p>
              {{ twitter.name }}
              <!-- <i class="iconf iconbianji" @click="_UpdateProperty"></i> -->
            </p>
            <div class="operation">
              <!-- <p class="linkSetDetail" @click="linkSetDetail">
                档案信息不够丰富？点击添加更多线索
              </p> -->
              <button class="btn update" @click="_TwitterAccountUpdate()">
                更新档案
              </button>
              <!-- <a href="javascript:;" class="btn down">导出报告</a> -->
            </div>
          </div>
          <p class="time">
            <span>上次更新时间：{{ twitter.updateTime }}</span>
            <span>当前更新进度：{{ twitter.progress }}%</span>
          </p>
          <div class="label">
            <p
              class="label-list"
              :class="LabelshowAll ? 'overf' : ''"
              ref="labelList"
            >
              <span v-for="(item, index) in twitter.label" :key="index">{{
                item
              }}</span>
            </p>
            <div class="label-set">
              <!-- <i class="iconf iconbianji"></i> -->
              <span
                class="more"
                v-if="LabelButtonShow"
                @click="LabelshowAll = !LabelshowAll"
              >
                查看更多<i
                  :class="[
                    'jt',
                    'el-icon-d-arrow-right',
                    !LabelshowAll ? 'rot' : '',
                  ]"
                ></i>
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <ul class="tab">
      <li :class="tabType == 0 ? 'active' : ''" @click="setTabType(0)">简介</li>
      <li :class="tabType == 1 ? 'active' : ''" @click="setTabType(1)">
        能影响谁
      </li>
      <li :class="tabType == 2 ? 'active' : ''" @click="setTabType(2)">
        被谁影响
      </li>
      <!-- <li :class="tabType == 3 ? 'active' : ''" @click="setTabType(3)">
        被谁反对
      </li> -->
    </ul>
    <ul class="child-tab" v-show="tabType != 0">
      <li
        :class="childTabType == 0 ? 'active' : ''"
        @click="setChildTabType(0)"
        v-show="tabType == 2"
      >
        人物({{ perNumber }})
      </li>
      <li
        :class="childTabType == 1 ? 'active' : ''"
        @click="setChildTabType(1)"
        v-show="tabType == 2"
      >
        机构({{ orgNumber }})
      </li>
      <li
        :class="childTabType == 2 ? 'active' : ''"
        @click="setChildTabType(2)"
      >
        推特({{ twitterNumber }})
      </li>
    </ul>
    <div class="cont-body" v-show="tabType == 0">
      <div class="body-left">
        <div class="basic-info">
          <p class="txt">{{ twitterInfo.description }}</p>
          <ul class="basic-ul">
            <li>
              <span class="ellipsis s1">TwitterId</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.twitterId }}
              </p>
            </li>
            <li>
              <span class="ellipsis s1">Twitter URL</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.homePage }}
              </p>
            </li>
            <li>
              <span class="ellipsis s1">注册地点</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.location }}
              </p>
            </li>
            <li>
              <span class="ellipsis s1">注册时间</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.createTime }}
              </p>
            </li>
            <li>
              <span class="ellipsis s1">语种</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.lang }}
              </p>
            </li>
            <li>
              <span class="ellipsis s1">个人主页</span>
              <p slot="reference" class="p2 ellipsis">
                {{ twitterInfo.homePage }}
              </p>
            </li>
          </ul>
          <p class="all">
            <span>
              <i class="iconf icontwitter"></i>
              推文数：{{ twitterInfo.twitterCount }}
            </span>
            <span>
              <i class="iconf iconwujiaoxing"></i>
              关注：{{ twitterInfo.followingCount }}
            </span>
            <span>
              <i class="iconf iconxin"></i>
              粉丝：{{ twitterInfo.followerCount }}
            </span>
            <span>
              <i class="iconf icondianzan_kuai"></i>
              点赞：{{ twitterInfo.likeCount }}
            </span>
            <span>
              <i class="iconf iconliebiao"></i>
              列表：{{ twitterInfo.listedCount }}
            </span>
          </p>
        </div>
        <div
          class="info-box"
          v-loading="loading1"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
        >
          <p class="tit">账号变更</p>
          <ul class="basic-ul">
            <li>
              <p class="p1">时间</p>
              <p class="p1">类型</p>
              <p class="p1">变更前</p>
              <p class="p1">变更后</p>
            </li>
            <li v-for="(item, index) in changeInfo" :key="index">
              <p class="p1 ellipsis2">{{ item.changeTime }}</p>
              <p class="p1 ellipsis2">{{ item.changeType }}</p>
              <p class="p1 ellipsis2">
                <template v-if="item.changeType != '头像'">
                  {{ item.afterChange }}
                </template>
                <img class="tx" v-else :src="item.afterChange" alt="" />
              </p>
              <p class="p1 ellipsis2">
                <template v-if="item.changeType != '头像'">
                  {{ item.beforeChange }}
                </template>
                <img class="tx" v-else :src="item.beforeChange" alt="" />
              </p>
            </li>
          </ul>
          <div class="pagination">
            <el-pagination
              :hide-on-single-page="isShow"
              class="pagination"
              background
              layout="prev, pager, next"
              :total="changeTotal"
              :page-size="5"
              @current-change="handleChangeQT"
            >
            </el-pagination>
          </div>
        </div>
        <div
          class="info-box"
          v-loading="loading2"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
        >
          <p class="tit">推文展示</p>
          <ul class="basic-tw">
            <li v-for="(item, index) in twInfo" :key="index">
              <div class="tit">
                <p class="tit-left">
                  <i class="iconf iconshijian"></i>
                  <span class="time">2020-08-27 0:17</span>
                  <span class="type">{{ item.tweetType }}</span>
                </p>
                <p class="num">
                  <span>
                    <i class="iconf icondianzan_kuai"></i>
                    {{ item.favorite_count }}
                  </span>
                  <span>
                    <i class="iconf iconzhuanfa"></i>
                    {{ item.retweet_count }}
                  </span>
                </p>
              </div>
              <p class="txt">
                Hurricane Laura is a very dangerous and rapidly intensifying
                hurricane. My Administration remains fully engaged with state &
                local emergency managers to continu Laura is a very dangerous
                and rapidly intensifying hurricane. My Administration remains
                fully engaged with state & local
              </p>
            </li>
          </ul>
          <div class="pagination">
            <el-pagination
              :hide-on-single-page="isShow"
              class="pagination"
              background
              layout="prev, pager, next"
              :total="changeTotal"
              :page-size="5"
              @current-change="handleChangetwInfo"
            >
            </el-pagination>
          </div>
        </div>
      </div>
      <div class="body-right">
        <ul class="body-right-ul" v-loading="accountLoading">
          <li class="tit-li">
            <p class="tit">关联人物</p>
            <el-button
              class="addTwitter"
              icon="el-icon-plus"
              type="primary"
              size="small"
              @click="dialogVisible = true"
              >添加人物</el-button
            >
          </li>
          <li class="item" v-for="(item, index) in twitterAccount" :key="index">
            <div class="user">
              <img :src="item.headUrl" alt="" />
              <div>
                <p class="ellipsis">{{ item.accountName }}</p>
                <span v-if="!item.verified">可能关联推荐</span>
                <p v-if="item.verified" class="txt">{{ item.description }}</p>
              </div>
              <el-button
                v-if="!item.verified"
                v-loading="item.loading"
                @click="_VerifyRelation(item)"
                class="guanlian"
                size="mini"
                plain
                >关联当前档案</el-button
              >
            </div>
            <p v-if="!item.verified" class="txt">{{ item.description }}</p>
          </li>
          <no-data :length="twitterAccount.length" :loading="accountLoading"></no-data>
        </ul>
        <div class="chart-box">
          <p class="tit">推文分析</p>
          <col-bar
            id="twfx"
            title="推文类型"
            :yAxisData="gxYAxisData"
            :seriesData="gxSeriesData"
          ></col-bar>
          <bar
            id="twyy"
            title="推文语言"
            :xAxisData="bqYAxisData"
            :seriesData="bqSeriesData"
          ></bar>
        </div>
      </div>
    </div>
    <div class="cont-body" v-show="tabType != 0">
      <div class="body-left" v-loading="leftLoading">
        <ul class="item-ul">
          <li class="info-item" v-for="(item, index) in DataList" :key="index">
            <img class="pic" :src="item.headUrl" alt="" />
            <div class="info">
              <div class="name" v-show="childTabType != 2">
                {{ item.entityName }}
                <i class="iconf iconshanchu"></i>
              </div>
              <div class="name" v-show="childTabType == 2 && tabType == 1">
                {{ item.twitterName }}
                <span class="num">{{ `提及人物${item.twitterNumber}次` }}</span>
              </div>
              <div class="name" v-show="childTabType == 2 && tabType == 3">
                {{ item.entityName }}
                <span
                  class="num"
                  v-for="(label, indexs) in item.relationTypeList"
                  :key="indexs"
                  >{{ label }}</span
                >
              </div>
              <p class="txt ellipsis2" v-show="childTabType != 2">
                {{ item.evidence }}
              </p>
              <p
                class="txt ellipsis2"
                v-show="childTabType == 2 && tabType == 1"
              >
                {{ item.twitterContext }}
              </p>
              <p
                class="txt ellipsis2"
                v-show="childTabType == 2 && tabType == 3"
              >
                {{ item.evidence }}
              </p>
              <div class="label-list" v-show="childTabType != 2">
                <span
                  v-for="(label, indexs) in item.relationTypeList"
                  :key="indexs"
                  >{{ label }}</span
                >
              </div>
              <p class="href" v-show="childTabType == 2 && tabType == 1">
                {{ item.twitterUrl }}
              </p>
              <p class="href" v-show="childTabType == 2 && tabType == 3">
                {{ item.srcUrl }}
              </p>
            </div>
          </li>
        </ul>
        <no-data :length="DataList.length" :loading="leftLoading"></no-data>
        <el-pagination
          :hide-on-single-page="DataList.length <= 10"
          class="pagination"
          background
          layout="prev, pager, next"
          :total="total"
          :current-page.sync="pageNum"
          prev-text="上一页"
          next-text="下一页"
          @current-change="handleChange"
        >
        </el-pagination>
      </div>
      <div class="body-right">
        <div class="chart-box">
          <col-bar
            id="relationship"
            :title="setTitBar"
            :yAxisData="gxYAxisData"
            :seriesData="gxSeriesData"
          ></col-bar>
        </div>
        <div
          class="chart-box"
          v-show="tabType == 1 || (tabType == 2 && childTabType == 2)"
        >
          <col-bar
            id="relationship2"
            title="互动分布"
            :yAxisData="gxYAxisData"
            :seriesData="gxSeriesData"
          ></col-bar>
        </div>
        <div class="chart-box">
          <pie id="address" :title="setTitPie" :seriesData="dySeriesData"></pie>
        </div>
        <div class="chart-box">
          <bar
            id="label"
            :title="setTitBarC"
            :xAxisData="bqYAxisData"
            :seriesData="bqSeriesData"
          ></bar>
        </div>
      </div>
    </div>
    <el-dialog :visible.sync="dialogVisible" center width="900px">
      <div class="dialog-box">
        <div class="search">
          <input
            v-model="searchMsg"
            type="text"
            placeholder="请输入搜索关键词"
            autocomplete="off"
          />
          <i class="icon el-icon-search" @click="_GetPersonRecord(false)"></i>
        </div>
        <ul
          class="dia-ul"
          v-loading="loadingDia"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
        >
          <li class="item" v-for="(item, index) in diaTwitterData" :key="index">
            <img :src="item.headUrl" alt="" />
            <div class="info-box">
              <div class="info">
                <p class="name">
                  <span>{{ item.entityName }}</span>
                  <el-button
                    v-loading="item.loading"
                    class="btn"
                    type="primary"
                    @click="_TwitterAddRelation(item)"
                    @keyup.enter="_TwitterAddRelation(item)"
                    >关联档案</el-button
                  >
                </p>
                <p class="label-list ellipsis">
                  <span
                    v-for="(labels, indexs) in item.labelTypes"
                    :key="indexs"
                    >{{ labels }}</span
                  >
                </p>
                <p class="txt ellipsis2">{{ item.abstractType }}</p>
              </div>
            </div>
          </li>
        </ul>
        <p class="more" @click="_GetPersonRecord(true)">
          <span> 查看更多 <i class="jt el-icon-d-arrow-right"></i> </span>
        </p>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  SynopsisDetails,
  GetBasicInfoById,
  QueryChangeInfo,
  TwitterList,
  QueryTwitterRelatedAccount,
  GetPersonRecord,
  TwitterAddRelation,
  UpdateProperty,
  TweetAnalysis,
  Tweetinfluence,
  TwitterGetInfluence,
  QueryBeImpactedPropertyAnalysis,
  TwitterQueryPropertyAnalysis,
  TwitterGetBeImpacted,
  VerifyRelation,
  GetInfluenceNumber,
  TwitterAccountUpdate,
  QueryEntityUpdateProgressRate
} from "@/api/twitter";
import { tipErr, tipSuc, tipWarn, formatDate } from "@/utils/index";

export default {
  data() {
    return {
      accountLoading:false,
      dialogVisible: false,
      loadingDia: false,
      diaTwitterData: [],
      searchMsg: "",
      diaPageNum: 0,
      leftLoading: false,
      loading1: false,
      loading2: false,
      total: 100,
      pageSize: 10,
      pageNum: 1,
      entityId: null, //人物id
      tabType: 0, //选项卡
      childTabType: 0, //子级选项卡
      LabelButtonShow: false, //查看更多按钮显示开关
      LabelshowAll: false, //标签全部显示开关
      /* 人物基本信息 */
      twitter: {
        name: "",
        updateTime: "",
        progress: "",
        label: [],
        abstractType: "",
      },
      twitterInfo: {
        createTime: "",
        description: "",
        entityId: "",
        followerCount: "",
        followingCount: "",
        homePage: "",
        influence: null,
        lang: "",
        likeCount: "",
        listedCount: "",
        location: null,
        mentionNum: null,
        mentionedNum: null,
        publisher: "",
        publisherName: "",
        twitterCount: "",
        twitterId: "",
      },
      changeTotal: 5,
      changeTotalPageNum: 0,
      changeInfo: [],
      twtTotal: 5,
      twtTotalPageNum: 0,
      twInfo: [
        {
          publisher_time: "2020/20/12",
          tweetType: "原创",
          favorite_count: 1200,
          retweet_count: 100,
          content: "",
        },
      ],
      /**基本信息结束 */
      // 关联推特
      twitterAccount: [],
      archives: [],
      // 影响、被影响、反对数据
      DataList: [],
      //关系分布数据
      gxYAxisData: [],
      gxSeriesData: [],
      //互动分布数据
      gxHYAxisData: [],
      gxHSeriesData: [],
      //地域分布
      dySeriesData: [],
      //标签分布数据
      bqYAxisData: [],
      bqSeriesData: [],
      perNumber: 0,
      orgNumber: 0,
      twitterNumber: 0,
    };
  },
  computed: {
    setTitBar() {
      let txt;
      if (this.tabType == 1) {
        txt = "关系分布";
      } else {
        if (this.childTabType != 2) {
          txt = "提及次数分布";
        } else {
          txt = "关系分布";
        }
      }
      return txt;
    },
    setTitBarC() {
      let txt;
      if (this.tabType == 1) {
        txt = "语种分布";
      } else {
        if (this.childTabType == 0) {
          txt = "标签分布";
        } else if (this.childTabType == 1) {
          txt = "机构类型";
        } else txt = "语种分布";
      }
      return txt;
    },
    setTitPie() {
      let txt;
      if (this.tabType == 1) {
        txt = "归属地分布";
      } else {
        if (this.childTabType != 2) txt = "地域分布";
        else txt = "归属地分布";
      }
      return txt;
    },
    isShow: function() {
      return this.changeTotal <= 5 ? true : false;
    },
    childIsShow: function() {
      return this.childTotal <= 5 ? true : false;
    },
    actIsShow: function() {
      return this.twtTotal <= 5 ? true : false;
    },
  },
  created() {
    this.entityId = this.$route.query.entityId;
    this.twitter.name = this.$route.query.name;
    this.twitter.abstractType = this.$route.query.abstractType;
    this._GetBasicInfoById();
    this._SynopsisDetails();
    this._QueryChangeInfo(this.changeTotalPageNum);
    this._TwitterList(this.twtTotalPageNum);
    this._QueryTwitterRelatedAccount();
    this._TweetAnalysis();
    this._TwitterAccountUpdate()
  },
  async mounted() {},
  beforeDestroy(){
    clearTimeout(this.timeOut)
    this.timeOut = null
  },
  methods: {
    async _QueryEntityUpdateProgressRate() {
      let { data, code, msg } = await QueryEntityUpdateProgressRate({
        entityId: this.entityId,
        twitter: true,
        type:'ACCOUNT_TWITTER'
      });
      if (code == 1) {
        this.twitter.progress = data.progress;
        if(data.progress<100){
         this.timeOut =  setTimeout(()=>{
           console.log(1)
           clearTimeout(this.timeOut)
           this.timeOut=null
           this._QueryEntityUpdateProgressRate()
        },20000)
        }
      }
    },
    async _TwitterAccountUpdate() {
      let { data, code, msg } = await TwitterAccountUpdate({
        accountId: this.entityId,
        appkey:"twitterAccountUpdateCrawler",
        accountName: this.twitter.name,
        entityType:"ACCOUNT_TWITTER"
      });
      if(code == 1){
        this._QueryEntityUpdateProgressRate();
      }else{
        tipErr('更新失败')
      }
    },
    async _GetBasicInfoById() {
      let { data, code, msg } = await GetBasicInfoById({
        entityId: this.entityId,
      });
      if (code == 1) {
        data.createTime = formatDate(data.createTime, "yy-MM-dd hh:mm:ss");
        this.twitterInfo = { ...data };
      } else {
        tipErr(msg);
      }
    },
    async _SynopsisDetails() {
      let { data, code, msg } = await SynopsisDetails({
        entityId: this.entityId,
        twitter: true,
        langType: "zh",
        type: "ACCOUNT_TWITTER",
      });
      if (code == 1) {
        data.updateTime = formatDate(data.updateTime, "yy-MM-dd hh:mm:ss");
        this.twitter = Object.assign(this.twitter, data);
        this.$nextTick(function() {
          let height = this.$refs.labelList.offsetHeight;
          if (height && height > 50) {
            this.LabelButtonShow = true;
            this.LabelshowAll = true;
          }
        });
      } else {
        tipErr(msg);
      }
    },
    async _QueryChangeInfo(index) {
      this.loading1 = true;
      let { data, total, code, msg } = await QueryChangeInfo({
        entityId: this.entityId,
        row: 5,
        start: index ? index * 5 : 0,
        groupName: "",
        sortRule: -1,
        changeTypeList: [
          "ATW_PUBLISHER",
          "ATW_PUBLISHER_NAME",
          "ATW_LOCATION",
          "ATW_DESCRIPTION",
          "head_protrait",
        ],
      });
      this.loading1 = false;
      if (code == 1) {
        this.changeTotal = total;
        this.changeTotalPageNum++;
        data.map((item) => {
          item.changeTime = formatDate(item.changeTime, "yy-MM-dd hh:mm");
          if (item.changeType == "ATW_PUBLISHER") {
            item.changeType = "推特名称";
          } else if (item.changeType == "ATW_PUBLISHER_NAME") {
            item.changeType = "推特账号";
          } else if (item.changeType == "ATW_LOCATION") {
            item.changeType = "账号注册地";
          } else if (item.changeType == "ATW_DESCRIPTION") {
            item.changeType = "个人描述";
          } else if (item.changeType == "head_protrait") {
            item.changeType = "头像";
          }
          return item;
        });
        this.changeInfo = [...data];
      } else {
        tipErr(msg);
      }
    },

    async _TwitterList(index) {
      this.loading3 = true;
      let { data, total, code, msg } = await TwitterList({
        entityId: this.entityId,
        row: 5,
        start: index ? index * 5 : 0,
        twitterOrPublicOpinion: true,
      });
      this.loading3 = false;
      if (code == 1) {
        this.twtTotal = total;
        this.twtTotalPageNum++;
        data.map((item) => {
          item.publishTime = formatDate(item.publishTime, "yy");

          return item;
        });
        this.twInfo = [...data];
      } else {
        tipErr(msg);
      }
    },
    async _QueryTwitterRelatedAccount() {
      this.accountLoading=true
      let { data, code, msg } = await QueryTwitterRelatedAccount({
        entityId: this.entityId,
        row: 10,
        start: 0,
      });
      this.accountLoading=false
      if (code == 1) {
        this.twitterAccount = [...data];
      } else {
        tipErr(msg);
      }
    },
    async _GetPersonRecord(index) {
      if (this.searchMsg == "") {
        tipWarn("请输入关键词~");
        return;
      }
      if (this.loadingDia) return;
      this.loadingDia = true;
      let { data, code, msg } = await GetPersonRecord({
        searchContent: this.searchMsg,
        recordScope: 0,
        row: 10,
        start: index ? this.diaPageNum * 10 : 0,
        type: "PERSON",
      });
      this.loadingDia = false;
      if (code == 1) {
        this.diaPageNum = index ? this.diaPageNum + 1 : 1;
        this.diaTwitterData = [...data.entityBasicInfoList];
      } else {
        tipErr(msg);
      }
    },
    async _TwitterAddRelation(item, json) {
      if (item.loading && 1) return;
      this.$set(item, "loading", true);
      let params = {
         inVertexId: item.entityId,
        outVertexId: this.entityId,
        mergerType: 1,
        edgeLabel: "PER_twitter_ATW",
        knowledgeFeature: {},
      };
      if (json) {
        params = Object.assign(params, json);
      }
      let { data, code, msg } = await TwitterAddRelation(params);
      item.loading = false;
      if (code == 1) {
        if (msg == "FAILED") {
          tipErr("关联失败");
        } else {
          if (data.mergerType == 2) {
            let me = this;
            this.$confirm(
              "",
              `此账号已经关联了档案${data.nameList[0]}，是否继续关联？如果关联的话，档案${data.nameList[0]}和档案${data.nameList[1]}将会被合并`,
              {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                center: true,
              }
            )
              .then(({ value }) => {
                me._TwitterAddRelation(item, { mergerType: 2 });
              })
              .catch(() => {});
          } else {
            tipSuc("关联成功");
            this._QueryTwitterRelatedAccount();
          }
        }
      } else {
        tipErr("关联失败");
      }
    },

    async _VerifyRelation(item) {
      if (item.loading && 1) return;
      this.$set(item, "loading", true);
      let { data, code, msg } = await VerifyRelation({
        inVertexId: item.entityId,
        outVertexId: this.entityId,
        edgeLabel: "PER_twitter_ATW",
        cancelOrVerify: 0,
        knowledgeFeature: {},
      });
      item.loading = false;
      if (code == 1) {
        if (msg == "FAILED") {
          tipErr("关联失败");
        } else {
          item.verified = true;
          tipSuc("关联成功");
        }
      } else {
        tipErr("关联失败");
      }
    },

    async _GetPersonList(index) {
      if (this.leftLoading) return;
      this.$set(this, "leftLoading", true);
      let params = this.setInfluenParams();
      params = Object.assign(params, {
        entityId: this.entityId,
        influenceType: this.tabType,
        rows: this.pageSize,
        start: index ? index * 10 : 0,
      });
      if (this.tabType == 1) {
        var { data, code, msg, total } = await Tweetinfluence({
           entityId: this.entityId,
        });
      } else if (this.tabType == 2) {
        if (this.childTabType == 0) {
          var { data, code, msg, total } = await TwitterGetBeImpacted(
            Object.assign(params, { entityType: "PER" })
          );
        } else if (this.childTabType == 1) {
          var { data, code, msg, total } = await TwitterGetBeImpacted(
            Object.assign(params, { entityType: "ORG" })
          );
        } else if (this.childTabType == 2) {
          var { data, code, msg, total } = await TwitterGetBeImpacted(params);
        }
      } else if (this.tabType == 3) {
         var { data, code, msg, total } = await TwitterGetBeImpacted(Object.assign(params,
         { entityType:'PER'}
        ));
      }
      this.leftLoading = false;
      if (code == 1) {
        this.total = total;
        if(data.length){
          data.forEach((item) => {
          if (item.relationTypeList && Array.isArray(item.relationTypeList)) {
            for (let i = 0; i < item.relationTypeList.length; i++) {
              item.relationTypeList[i] = this.setLabelTxt(
                item.relationTypeList[i]
              );
              console.log(item.relationTypeList[i]);
            }
          }
        });
        this.DataList = [...data];
        }else{
          this.DataList = [];
        }
      } else {
        tipErr(msg);
      }
    },
    async _TweetAnalysis() {
      // let entityType = this.setEntityType();
      let { data, code, msg } = await TweetAnalysis({
         entityId: this.entityId
      });
      if (code == 1) {
        let gxSeriesData = [],
          gxYAxisData = [];
        for (let key in data) {
          gxYAxisData.push(this.setLabelTxt(key));
          gxSeriesData.push(data[key]);
        }
        this.gxYAxisData = [...gxYAxisData];
        this.gxSeriesData = [...gxSeriesData];
      } else {
        tipErr(msg);
      }
    },
    async _TwitterQueryPropertyAnalysis() {
      let entityType = this.setEntityType();
      let { data, code, msg } = await TwitterQueryPropertyAnalysis({
        entityId: this.entityId,
        entityType: entityType,
        influenceType: this.tabType,
        rows: 10,
        start: 0,
      });
      if (code == 1) {
        let gxSeriesData = [],
          gxYAxisData = [];
        for (let key in data) {
          gxYAxisData.push(this.setLabelTxt(key));
          gxSeriesData.push(data[key]);
        }
        this.gxYAxisData = [...gxYAxisData];
        this.gxSeriesData = [...gxSeriesData];
      } else {
        tipErr(msg);
      }
    },
    async _QueryBeImpactedPropertyAnalysis() {
      let entityType = this.setEntityType();
      let { data, code, msg } = await QueryBeImpactedPropertyAnalysis({
        entityId: this.entityId,
        entityType: entityType,
        influenceType: this.tabType,
        rows: 10,
        start: 0,
      });
      if (code == 1) {
        let bqYAxisData = [],
          bqSeriesData = [];
        if (this.childTabType == 0) {
          this.dySeriesData = [...(data.PER_WORK_PLACE_P || [])];
          if (data.PER_LABEL != null) {
            data.PER_LABEL.forEach((item) => {
              bqYAxisData.push(item.name);
              bqSeriesData.push(item.value);
            });
          }
        } else if (this.childTabType == 1) {
          this.dySeriesData = [...(data.ORG_LOCATION_P || [])];
          if (data.ORG_TYPE != null) {
            data.ORG_TYPE.forEach((item) => {
              bqYAxisData.push(item.name);
              bqSeriesData.push(item.value);
            });
          }
        } else if (this.childTabType == 2) {
          this.dySeriesData = [...(data.ATW_LOCATION || [])];
          if (data.ATW_LANG != null) {
            data.ATW_LANG.forEach((item) => {
              bqYAxisData.push(item.name);
              bqSeriesData.push(item.value);
            });
          }
        }
        this.bqYAxisData = [...bqYAxisData];
        this.bqSeriesData = [...bqSeriesData];
      } else {
        tipErr(msg);
      }
    },
    async _GetInfluenceNumber() {
      let { data, code, msg } = await GetInfluenceNumber({
        entityId: this.entityId,
        entityType: "ATW_ATW",
        influenceType: this.tabType,
        rows: 10,
        start: 0,
      });
      if (code == 1) {
        this.perNumber = data.perNumber;
        this.orgNumber = data.orgNumber;
        this.twitterNumber = data.twitterNumber;
      } else {
        tipErr(msg);
      }
    },
    setLabelTxt(txt) {
      let msg;
      if (txt == "ORG_subordinate_ORG") {
        msg = "下属关系";
      } else if (txt == "ORG_cooperation_ORG") {
        msg = "合作关系";
      } else if (txt == "ORG_employee_PER") {
        msg = "雇员";
      } else if (txt == "ORG_cooperation_PER") {
        msg = "合作关系";
      } else if (txt == "PER_friend_PER") {
        msg = "朋友";
      } else if (txt == "PER_management_ORG") {
        msg = "管理层";
      } else if (txt == "ORG_parent_company_ORG") {
        msg = "隶属于";
      } else if (txt == "ORG_competition_ORG") {
        msg = "对立关系";
      } else if (txt == "PER_competition_ORG") {
        msg = "对立关系";
      } else if (txt == "ATW_competition_ORG") {
        msg = "对立关系";
      } else if (txt == "a") {
        msg = "1-50";
      } else if (txt == "b") {
        msg = "50-100";
      } else if (txt == "c") {
        msg = "100-200";
      } else if (txt == "d") {
        msg = "200-500";
      } else if (txt == "e") {
        msg = "500次以上";
      }
      return msg;
    },
    setInfluenParams() {
      let params;
      if (this.childTabType == 0) {
        params = {
          entityType: "ORG_PER",
          relationFilters: [],
        };
      } else if (this.childTabType == 1) {
        params = {
          entityType: "ORG_ORG",
        };
      } else if (this.childTabType == 2) {
        params = {
          entityType: "ORG_ATW",
        };
      }

      return params;
    },
    setEntityType() {
      let entityType;
      if (this.childTabType == 0) {
        entityType = "ORG_PER";
      } else if (this.childTabType == 1) {
        entityType = "ORG_ORG";
      } else if (this.childTabType == 2) {
        entityType = "ORG_ATW";
      }
      return entityType;
    },
    setTabType(index) {
      this.tabType = index;

      if (!!index) {
        if (index == 2) {
          this.setChildTabType(0);
        } else {
          this.setChildTabType(2);
        }
        this._GetInfluenceNumber();
      }
    },
    setChildTabType(index) {
      this.childTabType = index;
      this.pageNum = 1;
      let myEvent = new Event("resize");
      window.dispatchEvent(myEvent);
      this._GetPersonList();
      if (this.tabType != 0) {
        this._TwitterQueryPropertyAnalysis();
        if (index != 2) {
          this._QueryBeImpactedPropertyAnalysis();
        }
      }
    },
    handleChangeQT(index) {
      this._QueryChangeInfo(index - 1);
    },
    handleChangetwInfo(index) {
      this._TwitterList(index - 1);
    },
    handleChange(index) {
      this._GetPersonList(index - 1);
    },
  },
};
</script>

<style lang="scss" scoped src="@/assets/css/detail.scss"></style>
<style lang="scss" scoped>
.all {
  display: flex;
  padding-left: 20px;
  border-bottom: 1px solid #24272e;
  span {
    margin-right: 40px;
    font-size: 14px;
    color: #b8becc;
    line-height: 52px;
  }
  .iconf {
    color: #b8becc;
  }
}
.basic-ul {
  li {
    height: 60px !important;
  }
  .p1 {
    line-height: 60px;
  }
  .tx {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    vertical-align: middle;
  }
}
.cont-body {
  .body-left {
    .basic-tw {
      padding-left: 10px;
      position: relative;
      overflow: hidden;
      border: none !important;
      &::after {
        position: absolute;
        top: 7px;
        left: 15.5px;
        content: "";
        width: 1px;
        height: 100%;
        background: #24282e;
      }
      li {
        height: auto;
        margin-bottom: 36px;
        display: block;
        border: none;
        &:first-child {
          background: transparent;
        }
        .tit {
          width: 100%;
          display: flex;
          justify-content: space-between;
          line-height: 24px;
          margin-bottom: 5px;
          &-left {
            display: flex;
          }
          .iconshijian {
            font-size: 12px;
            color: #6b6f80;
            margin-right: 19px;
            z-index: 1;
          }
          .time {
            font-size: 14px;
            color: #8a8e99;
            font-weight: 700;
            margin-right: 15px;
          }
          .type {
            height: 24px;
            padding: 0 10px;
            font-size: 14px;
            color: #cc7029;
            line-height: 24px;
            background: #15161a;
          }
          .num {
            display: flex;
            font-size: 12px;
            color: #8a8e99;
            font-weight: 500;
            span {
              margin-left: 48px;
            }
            .iconf {
              font-size: 16px;
            }
          }
        }
        .txt {
          padding-left: 30px;
          text-align: left;
          font-size: 14px;
          color: #b8becc;
          line-height: 20px;
        }
      }
    }
  }
}
.dialog-box {
  .dia-ul {
    .item {
      img {
        border-radius: 0;
      }
      .info {
        .name {
          padding-bottom: 6px;
        }
        .label-list {
          display: flex;
          margin-bottom: 8px;
          span {
            height: 28px;
            line-height: 28px;
            padding: 0 8px;
            font-size: 12px;
            color: #828999;
            background: #343842;
            margin-right: 10px;
          }
        }
        .txt {
          font-size: 14px;
          color: #b8becc;
          line-height: 20px;
        }
      }
    }
  }
}
.chart-box {
  .tit {
    font-size: 18px;
    color: #eee;
    font-weight: 700;
    margin-bottom: 28px;
  }
}
</style>
